package pl.SilverSable.Engine.graphics.animation;

import pl.SilverSable.Engine.Engine;
import pl.SilverSable.Engine.graphics.ColorFactory;
import pl.SilverSable.Engine.graphics.Paint;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Sprite {
	
	 public int        FRAME_COLS;         // #1
	 public int        FRAME_ROWS;         // #2
     
    // Animation                       walkAnimation;          // #3
     Texture                         walkSheet;              // #4
     TextureRegion[]                 walkFrames;             // #5
   //  SpriteBatch                     spriteBatch;            // #6
   //  TextureRegion                   currentFrame;           // #7
     
   //  float stateTime;                                        // #8
     
     public Sprite(Texture sprite, int cols, int rows){
    	 FRAME_COLS = cols;
    	 FRAME_ROWS = rows;
    	 
    //	 spriteBatch = Engine.batch;
    	 
    	 Texture texture = sprite;
    	 
    	 walkSheet = Paint.Transparent(texture, Paint.GetColor(texture, 0, 0)) 	;     // #9
         TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth() / 
        		 FRAME_COLS, walkSheet.getHeight() / FRAME_ROWS);                                // #10
         walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
         int index = 0;
         for (int i = 0; i < FRAME_ROWS; i++) {
                 for (int j = 0; j < FRAME_COLS; j++) {
                         walkFrames[index++] = tmp[i][j];
                 }
         }
     //    walkAnimation = new Animation(0.30f, walkFrames);              // #11
     //    spriteBatch = new SpriteBatch();                                // #12
     //    stateTime = 0f;                                                 // #13
    	 
     }
     
     	
     public TextureRegion GetTextureRegion(int id){
    	 
    	 return walkFrames[id];
    	 
     }

     
     public void Render() {
            // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);                                            // #14
          //   stateTime += Gdx.graphics.getDeltaTime();                       // #15
          //   currentFrame = walkAnimation.getKeyFrame(stateTime, true);      // #16
          //   spriteBatch.begin();
           //  spriteBatch.draw(currentFrame, 50, 50);                         // #17
           //  spriteBatch.end();
     }


}
